package com.ershu.book.service;

import java.util.List;

import com.ershu.book.dao.BookDao;
import com.ershu.book.domain.Book;
import com.ershu.picture.domain.Picture;
import com.ershu.picture.service.PictureService;
import com.ershu.user.domain.User;
import com.ershu.user.service.UserService;

public class BookService {

	private BookDao bookDao = new BookDao();
	private UserService userService = new UserService();
	private PictureService pictureService = new PictureService();
	
	/**
	 * 
	 * @param id
	 * @return book
	 * 闁俺绻僢ook閻ㄥ埇d閺屻儲澹樻稊锔芥拱閻ㄥ嫪淇婇幁锟�
	 */
	public Book findById(String id){
		Book book = bookDao.findById(id);
		User user = userService.findById(book.getUser().getId());
		book.setUser(user);
		List<Picture> imageList = pictureService.findById(book.getId());
		book.setImageList(imageList);
		
		return book;
	}
	
	/**
	 * 查找书本信息
	 * @param name
	 * @return
	 * @author zwy
	 */
	public Book findByName(String name) {
		Book book = bookDao.findByName(name);
		return book;
	}
	
	/**
	 * 
	 * @param book
	 * @author zwy
	 */
	public void insertBook(Book book) {
				
		bookDao.insertBook(book);

	}
}
